package com.ysyx.ysyx_admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysyx.ysyx_admin.dto.BaseDto;
import com.ysyx.ysyx_admin.mapper.AdminPojoMapper;
import com.ysyx.ysyx_admin.pojo.AdminPojo;
import com.ysyx.ysyx_admin.qo.AdminQo;
import com.ysyx.ysyx_admin.service.AdminPojoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.management.Query;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionIdListener;
import java.util.List;

/**
* @author Administrator
* @description 针对表【admin_inf(管理员表)】的数据库操作Service实现
* @createDate 2023-04-07 20:09:45
*/
@Service
public class AdminPojoServiceImpl extends ServiceImpl<AdminPojoMapper, AdminPojo>
    implements AdminPojoService{
    @Autowired
    private AdminPojoMapper adminPojoMapper;

    @Override
    public BaseDto getAdmin(AdminQo adminQo) {
        System.out.println("验证账号密码"+adminQo);
        BaseDto baseDto=null;
        if (adminQo.getCode().equals(adminQo.getHttpCode())){

//        加入匹配字段
//            QueryWrapper queryWrapper = new QueryWrapper();
//            queryWrapper.eq("admin_acc", adminQo.getAdminAcc());
//            queryWrapper.eq("admin_pwd", adminQo.getAdminPwd());
//        加条件
            List<AdminPojo> list = adminPojoMapper.adminLogin(adminQo);
            System.out.println(list);
//            是否有账号密码取回
            int size = list.size();
            if(size>0){
                baseDto = new BaseDto(101,"登录成功",list,null);
                return baseDto;
            }
            baseDto = new BaseDto(102,"账号有误",null,null);
            return baseDto;
        }
         baseDto = new BaseDto(103,"验证码有误",null,null);
        return baseDto;
    }
}




